package bancosys.tec.security.impl.services.incluir;

import jmine.tec.di.annotation.Injected;
import jmine.tec.services.annotations.Input;
import jmine.tec.services.annotations.ServiceImplementor;
import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.api.RawInput;
import jmine.tec.services.api.export.ReferenceMap;
import jmine.tec.services.export.impl.ExportUtils;
import jmine.tec.services.io.ServiceBean;
import bancosys.tec.security.impl.domain.AuthorizableCredential;

/**
 * Serviço para incluir Credenciais de entidades do domínio
 * 
 * @author seiti
 * @created Oct 11, 2010
 */
@ServiceImplementor(action = ActionsEnum.INCLUIR)
public class AuthorizableCredentialService extends AbstractCredentialService<AuthorizableCredential> {

    public static final String AUTHORIZABLE = "Autorizável";

    private RawInput rawInput;

    /**
     * {@inheritDoc}
     */
    @Override
    protected void fillCredential(AuthorizableCredential credential) {
        credential.setAuthorizable(this.rawInput.getRaw(AUTHORIZABLE));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void fillServiceBean(ServiceBean bean, ReferenceMap referenceMap, AuthorizableCredential entity) {
        super.fillServiceBean(bean, referenceMap, entity);
        ExportUtils.put(bean, AUTHORIZABLE, entity.getAuthorizable());
    }

    /**
     * @param rawInput the rawInput to set
     */
    @Injected
    public void setRawInput(RawInput rawInput) {
        this.rawInput = rawInput;
    }

    /**
     * @param authorizable to set
     */
    @Input(fieldName = AUTHORIZABLE)
    public void setAuthorizable(String authorizable) {
    }
}
